package top.yxqz.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author Mr.余
 * @date 2022/11/16
 * @package top.yxqz.jdbc
 */
public class JDBC {
    public static Connection getConnection(String url,String user,String password) throws SQLException, ClassNotFoundException {
        Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection(url, user, password);
        return  connection;
    }

    public static void main(String[] args) throws SQLException {
        String url = "jdbc:mysql://localhost:3306/student";
        String user = "root";
        String pwd = "111111";
        Connection connection = DriverManager.getConnection(url, user, pwd);
        if (connection!=null) System.out.println("数据链接成功");
    }
}
